package com.wenwan.manage.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

/**
 * 商品
 * 
 * @author Admin
 *
 */
@JsonInclude(Include.NON_NULL)
public class Goods implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4370873370077935809L;

	/**
	 * 商品id
	 */
	private String id;
	/**
	 * 创建 时间
	 */
	@JsonIgnore
	private String createTime;
	/**
	 * 更新时间
	 */
	@JsonIgnore
	private String updateTime;
	/**
	 * 发布者
	 */
	private String userId;
	/**
	 * 商品的二级分类
	 */
	private String goodsCategorySecondId;
	/**
	 * 商品标题
	 */
	private String title;
	/**
	 * 商品价格
	 */
	private Double price;
	/**
	 * 商品详情
	 */
	private String info;
	/**
	 * 轮播图，json格式的字符串数组
	 */
	@JsonIgnore
	private String imagesCarousel;
	/**
	 * 轮播图集合
	 */
	private List<String> imagesCarouselList = new ArrayList<String>();
	/**
	 * 图片详情，json格式的字符串数组
	 */
	@JsonIgnore
	private String imagesInfo;
	/**
	 * 图片详情集合
	 */
	private List<String> imagesInfoList = new ArrayList<String>();
	/**
	 * 第一张图片
	 */
	private String image;

	public Goods() {
		// TODO Auto-generated constructor stub
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getImagesCarousel() {
		return imagesCarousel;
	}

	public void setImagesCarousel(String imagesCarousel) {
		this.imagesCarousel = imagesCarousel;
	}

	public String getImagesInfo() {
		return imagesInfo;
	}

	public void setImagesInfo(String imagesInfo) {
		this.imagesInfo = imagesInfo;
	}

	public String getGoodsCategorySecondId() {
		return goodsCategorySecondId;
	}

	public void setGoodsCategorySecondId(String goodsCategorySecondId) {
		this.goodsCategorySecondId = goodsCategorySecondId;
	}

	public List<String> getImagesCarouselList() {
		if (imagesCarousel != null) {
			imagesCarouselList = new Gson().fromJson(imagesCarousel, new TypeToken<List<String>>() {
			}.getType());
		} else {
			imagesCarouselList = null;
		}
		return imagesCarouselList;
	}

	public void setImagesCarouselList(List<String> imagesCarouselList) {
		this.imagesCarouselList = imagesCarouselList;
	}

	public List<String> getImagesInfoList() {
		if (imagesInfo != null) {
			imagesInfoList = new Gson().fromJson(imagesInfo, new TypeToken<List<String>>() {
			}.getType());
		} else {
			imagesInfoList = null;
		}
		return imagesInfoList;
	}

	public void setImagesInfoList(List<String> imagesInfoList) {
		this.imagesInfoList = imagesInfoList;
	}

	public String getImage() {
		List<String> imageList = new ArrayList<String>();
		if (image != null) {
			imageList = new Gson().fromJson(image, new TypeToken<List<String>>() {
			}.getType());
			if (imageList != null && imageList.size() > 0) {
				return imageList.get(0);
			}
		} else {
			imagesInfoList = null;
		}
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

}
